package com.xiaobaibai.vo;

import com.xiaobaibai.entity.OrderItem;
import com.xiaobaibai.entity.Product;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class OrderItemVo {

    /**
     * 客户端用来做订单详细页
     */
    private Integer orderItemId;//小订单id

    private Integer productId;//商品id

    private String productName;//商品名称

    private String productImage;//商品图片

    private BigDecimal productPrice;//单个商品价格

    private Integer productCount;//商品数量

    private BigDecimal itemPrice;//总计

    public static OrderItemVo convertOrderItemVo(Product product, OrderItem orderItem){
        OrderItemVo orderItemVo=new OrderItemVo();
        orderItemVo.setProductId(orderItem.getProductId());
        orderItemVo.setProductName(product.getProductName());
        orderItemVo.setProductImage(product.getProductImage().get(0));
        orderItemVo.setProductPrice(orderItem.getProductPrice());
        orderItemVo.setProductCount(orderItem.getProductCount());
        orderItemVo.setItemPrice(orderItem.getItemPrice());
        orderItemVo.setOrderItemId(orderItem.getId());
        return orderItemVo;
    }

}
